﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Entity;

namespace BookStore.Controllers
{
    public class ShopcartController : Controller
    {
        //
        // GET: /Shopcart/
        //购物车
        public ActionResult Index()
        {
            //账号已经登陆
            if (Request.Cookies["User"] != null)
            {
                //数据库获取购物车信息
            }
            else { 
            //session获取数据显示


            }
            return View();
        }
        
        public ActionResult Showcar(int BookId, int quantity)
        {
            List<ShoppingCart> list = new List<ShoppingCart>();
            //判断购物车有无商品
            if (Session["shopcart"] == null)
            {
               
                ShoppingCart sc = new ShoppingCart();
                sc.BookId = BookId;
                sc.CartCount = quantity;
                list.Add(sc);
                Session["shopcart"] = list;
                //如果账号已经登陆
                if (Request.Cookies["User"] != null)
                {
                    int name =Convert.ToInt32( Request.Cookies["User"].Values["Userid"]);
                    sc.UserID = name;
                   
                  
                }
            }
            else { 
            
            }
            return View();
        }
    }
}
